﻿using blackhouse.BlackApart.Business.Reservations;

namespace blackhouse.BlackApart.Web.Navigation {
    public class ReservationPage {

        #region Fields

        public IWebReservation Reservation { get; private set; }
        public int ApartmentTypeId { get; private set; }
        public ReservationSubpageType Type { get; private set; }
        public SearchState State { get; private set; }

        #endregion

        #region Properties

        public int OverrideLanguageSiteId { get; set; }

        public bool OrderingBreakfasts { get; set; }

        #endregion

        #region Constructors

        private ReservationPage(IWebReservation reservation, int apartmentTypeId, ReservationSubpageType type) {
            this.Reservation = reservation;
            this.ApartmentTypeId = apartmentTypeId;
            this.Type = type;
        }

        #endregion

        #region Methods

        public void Visit(IReservationPageVisitor visitor) {
            visitor.Apply(this);
        }

        public static ReservationPage GetInformationPage(int apartmentTypeId) {
            return GetInformationPage(apartmentTypeId, SearchState.GetFromContext());
        }

        public static ReservationPage GetInformationPage(int apartmentTypeId, SearchState overrideSearch) {
            var p = new ReservationPage(null, apartmentTypeId, ReservationSubpageType.Information);
            p.State = overrideSearch;
            return p;
        }

        public static ReservationPage GetPreInformationPage(int apartmentTypeId) {
            return GetPreInformationPage(apartmentTypeId, SearchState.GetFromContext());
        }


        public static ReservationPage GetPreInformationPage(int apartmentTypeId, SearchState overrideSearch) {
            var p = new ReservationPage(null, apartmentTypeId, ReservationSubpageType.PreInformation);
            p.State = overrideSearch;
            return p;
        }

        public static ReservationPage GetContactPage(IWebReservation reservation) {
            return new ReservationPage(reservation, 0, ReservationSubpageType.Contact);
        }

        public static ReservationPage GetServicesPage(IWebReservation reservation) {
            return new ReservationPage(reservation, 0, ReservationSubpageType.AdditionalServices);
        }

        public static ReservationPage GetPaymentPage(IWebReservation reservation) {
            return new ReservationPage(reservation, 0, ReservationSubpageType.Payment);
        }

        public static ReservationPage GetEndPage(IWebReservation reservation) {
            return new ReservationPage(reservation, 0, ReservationSubpageType.EndReservation);
        }

        public static ReservationPage GetStatusPage(IWebReservation reservation) {
            return new ReservationPage(reservation, 0, ReservationSubpageType.Status);
        }

        public static ReservationPage GetConfirmationPage(IWebReservation reservation) {
            return new ReservationPage(reservation, 0, ReservationSubpageType.Confirm);
        }

        public static ReservationPage GetProcessPayPage(IWebReservation reservation) {
            return new ReservationPage(reservation, 0, ReservationSubpageType.PayReservation);
        }

        #endregion

    }
}